package com.tbit.main.controller;

import com.tbit.main.common.JsonResult;
import com.tbit.main.h2.pojo.ParkPoint;
import com.tbit.main.pojo.Machine;
import com.tbit.main.pojo.MachineStatus;
import com.tbit.main.pojo.Point;
import com.tbit.main.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 测试
 *
 * @author LMY
 * @create 2022-04-26 14:33
 */
@RestController
@RequestMapping("/terControl")
public class TestController {

    @Autowired
    private TokenService tokenService;
    @Autowired
    private ParkPointService parkPointService;
    @Autowired
    private MachineService machineService;
    @Autowired
    private MachineStatusService machineStatusService;
    @Autowired
    private DataService dataService;
    @Autowired
    private CalibrateService calibrateService;

    /**
     * 站点
     *
     * @param token
     * @param userCode
     * @return
     */
    @RequestMapping("/parkPoint")
    public JsonResult parkPoint(String token, String userCode) {

        MachineStatus machineStatus = machineStatusService.getByMachineId(dataService.getMachineId(dataService.getMachineNO(userCode)));

        Machine machine = machineService.getByUseCode(userCode);

        /**判断是站外*/
        ParkPoint parkPoint = parkPointService.checkInParkPoint(machine.getAccountId(), new Point(machineStatus.getLon(), machineStatus.getLat()), 300, null);

        return JsonResult.succ(parkPoint);
    }

    /**
     * 测试
     *
     * @param token
     * @return
     */
    @RequestMapping("/money")
    public JsonResult money(String token) {

        dataService.operationalDataToMain();
        return JsonResult.succ();
    }

}
